<?php
if (count($this->messages) > 0) {
    foreach ($this->messages as $message) {
        if (strpos($message, "successfully")) {
            ?>
            <div class="alert alert-success alert-dismissable">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <?php
                echo "<strong>$message</strong>";
                echo '</div>';
            } else {
                ?>
                <div class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <?php
                    echo "<strong>$message</strong>";
                    echo '</div>';
                }
            }
        }
        ?>

        <div id="delete_div" class="alert alert-danger fade in">

            <h4><strong>Delete Action!</strong></h4>
            <p>Are you sure that you want to delete this item ?</p>
            <p>
                <a id="delete_action" class="btn btn-danger" href="#">Ok, Delete</a> <a id="keep_action" class="btn btn-default"  href="#">No, Keep it</a>
            </p>
        </div>
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">List News</h3>
            </div>
            <div class="panel-body">
                <div class="pull-right"><a id="addAction" class="btn btn-primary " href="<?php echo $this->baseUrl() ?>/administration/news/add"><span class="glyphicon glyphicon-plus"></span> Add Article</a></div>
                <?php
                if (count($this->paginator)) {
                    ?>

                    <table class="table table-hover">
                        <thead>
                        <th>Id</th>
                        <th>Title</th>
                        <th>Category</th>
                        <th>Created By</th>
                        <th>Created On</th>
                        <th>Actions</th>
                        </thead>
                        <tbody>
    <?php
    foreach ($this->paginator as $event) {
        
        echo "<tr>";
        echo "<td>" . $event['nId'] . "</td>";
        echo "<td>" . $event['title']."</td>";
        echo "<td>" . $event['name']."</td>";
        echo "<td>" . $event['firstName']." ".$event['lastName']."</td>";
        echo "<td>" . $event['createdOn'] . "</td>";
        echo '<td><a href="' . $this->baseUrl() . '/administration/news/edit/id/' . $event['nId'] . '"><i class="glyphicon glyphicon-edit"></i></a>';
        echo '<a href="#"><i class="glyphicon glyphicon-remove" id="delete_' . $event['nId'] . '"></i></a>';

        echo '</td>';
        echo "</tr>";
    }
    ?>
                        </tbody>
                    </table>

                            <?php
                            echo $this->paginationControl($this->paginator, 'sliding', 'pagination.phtml');
                        } else {
                            ?>
                    <div>You do not have any articles</div>
                <?php } ?>
            </div>
        </div>
